import request from "../index";
import type { ResultData } from "../index";
export interface ISuggestList {
  id: number;
  defaultKey: string;
  configKey: any[];
}

export interface IBanner {
  id: number;
  picId?: string;
  picStr?: string; // 图片
  backendPicId: string;
  backendPicStr?: string;
  url?: string;
}

export interface ICategory {
  cid: number;
  picStr?: string; // 图片
  title?: string;
  tabIndex?: number;
  desc?: string;
  count?: number;
  type?: number;
  targetUrl?: string;
}

export interface IRecommend {
  id: number;
  picStr?: string;
  title?: string;
}

export interface IDigital {
  digitalIcon?: string;
  name?: string;
  desc?: string;
  buyNow?: string;
  picStr?: string;
  picStr1?: string;
  picStr2?: string;
}

export interface IHomeInfo {
  banners: IBanner[];
  categorys: ICategory[];
  recommends: IRecommend[];
  digitalData: IDigital;
}

export interface IHotProduct {
  id?: number;
  name?: string;
  products: IProduct[];
}

export interface IProduct {
  id?: number;
  type?: string;
  name?: string;
  minPrice?: string;
  maxPrice?: string;
  originalCost?: string;
  couponLabelDesc?: string;
  coverUrl?: string;
}

export interface IRecommendHotProduct {
  count: number;
  hasMore?: boolean;
  hotProduct?: IHotProduct[];
}

// export interface IProductA {
//   id?: number;
//   type?: number;
//   brandName?: string;
//   name?: string;
//   minPrice?: string;
//   maxPrice?: string;
//   originalCost?: string;
//   coverUrl?: string;
// }

export interface IAllProduct {
  count?: number;
  allProduct?: IProduct[];
}

// 获取搜索推荐
export const getSearchList = () => {
  return request.get<ResultData<ISuggestList>>("/searchsuggest/get");
};

// 首页信息
export const getHomeInfo = () => {
  return request.get<ResultData<IHomeInfo>>("/home/info");
};

// 推荐商品
export const getHotProduct = () => {
  return request.get<ResultData<IRecommendHotProduct>>("/hotproduct_v2/gets");
};

// 热门商品
export const getAllProduct = () => {
  return request.get<ResultData<IAllProduct>>("/allProduct/gets");
};
